import request from "@/utils/request";

// 生成订单
export function createOrder(data: { address_id: number | string; items: Array<{ book_id: number | string; quantity: number }> }) {
    return request({
        url: '/orders',
        method: 'post',
        data
    })
}

// 获取订单列表
export function fetchOrders(params: { page?: number; size?: number; status?: string } = {}) {
    return request({
        url: '/orders',
        method: 'get',
        params
    })
}

// 获取订单详情
export function fetchOrderDetail(orderId: number | string) {
    return request({
        url: `/orders/${orderId}`,
        method: 'get'
    })
}

// 取消订单
export function cancelOrder(orderId: number | string) {
    return request({
        url: `/orders/${orderId}/cancel`,
        method: 'put'
    })
}